package com.stu;

import java.util.Scanner;

public class MainStu {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()){

            String s = sc.next();
            //去除中括号
            String str = s.substring(1, s.length() -1);
            String ss[] = str.split(",");
            int a[] = new int[ss.length];
            for(int i = 0; i < ss.length; i++){
                a[i] = Integer.parseInt(ss[i]);
            }
            boolean bl = false;
            int count = 0;
            int f = 0;
            while (count <= a.length){
                count ++;
                f += a[f];
                if(f < 0 || f >= a.length){
                    bl = true;
                    break;
                }
            }
            System.out.println(bl);

        }

    }

}
